<div class="jobs view">
<div class="widget" id="widget_job_view" style="width: 96%">
    <div class="toggle">&nbsp;</div>
    <h3 class="handle"><?php printf(__('View Job By Company (%s)', true), $company['Company']['name']);?></h3>
    <div class="content">
    <?php if(count($jobs) > 1): ?>
        <!-- to avoid two loops over the same array -->
        <ul class="titles" id="job_titles"></ul>
        <div class="contents" id="job_contents"></div>
        <!-- loop to create titles and job contents -->
        <?php foreach($jobs as $i=>$job): ?>
            <li class="job_title"
                    id="job_title_<?php e($job['Job']['id']); ?>"
                    target="#job_content_<?php e($job['Job']['id']); ?>"><?php e($job['Job']['title']); ?></li>
            <div class="job_content" id="job_content_<?php e($job['Job']['id']); ?>">
                <?php e($this->element('view_job', array('job'=>$job, 'company'=>$company))); ?>
            </div>
        <?php endforeach; ?>
        <!-- bind Job title toggler for job content -->
        <script type="text/javascript">
            jQuery(function(){
                var titles = $('li.job_title'), contents = $('div.job_content');
                contents.hide().appendTo($('div.content'));
                titles.click(function(){
                    $('div.job_content:visible').hide();
                    $($(this).attr('target')).show();
                }).appendTo($('ul.titles'));
                $('ul.titles').append('<br class="clear"/>');
                $('li.job_title:first').click();
            });
        </script>
    <?php else: ?>
        <?php e($this->element('view_job', array('job'=>$jobs[0], 'company'=>$company))); ?>
    <?php endif; ?>
    </div>
</div>
</div>
<?php if($user['group'] == 'student'): ?>
<!-- Script for ajax job apply -->
<script type="text/javascript">
    jQuery(function(){
        $('a.link_apply_for_the_job').click($.sme.cbk.ajaxApply);
    });
</script>
<?php endif; ?>